import http from "@/utils/http";
import { AxiosRequestConfig } from "axios";

export interface GetBoardDir_ {
  /**
   * @description 看板目录层级
   * @format int32
   */
  level?: number;
  /**
   * @description 看板父目录的id
   * @format int32
   */
  parentDirId?: number;
}
export interface GetBoardDirTree_ {
  /**
   * @description name
   */
  name?: string;
}
export interface PutBoardDirById_ {
  /**
   * @description 看板的id
   */
  id: number;
}
export interface DeleteBoardDirById_ {
  /**
   * @description 看板的id
   */
  id: number;
}

export class PublicBoardDir {
  /**
   * 搜索文件夹，提供按层级查询文件夹的功能
   *
   * @tags 公共看板目录模块
   * @request GET: /board-dir
   * @secure
   */
  getBoardDir = (query: { level?: number; parentDirId?: number } | GetBoardDir_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityListPublicBoardDirVO>({
      url: `/board-dir`,
      method: "GET",
      params: query,
      ...params,
    });

  /**
   * 添加看板目录，可提供上/下方增加文件夹、增加文件夹的功能
   *
   * @tags 公共看板目录模块
   * @request POST: /board-dir
   * @secure
   */
  postBoardDir = (boardDirDTO: defs.BoardDirDTO, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityString>({
      url: `/board-dir`,
      method: "POST",
      data: boardDirDTO,
      ...params,
    });

  /**
   * 搜索看板目录树, 提供按目录名模糊查询的功能
   *
   * @tags 公共看板目录模块
   * @request GET: /board-dir/tree
   * @secure
   */
  getBoardDirTree = (query: { name?: string } | GetBoardDirTree_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityPublicBoardDirTreeNodeVO>({
      url: `/board-dir/tree`,
      method: "GET",
      params: query,
      ...params,
    });

  /**
   * 修改看板目录，支持修改父级、重命名功能
   *
   * @tags 公共看板目录模块
   * @request PUT: /board-dir/{id}
   * @secure
   */
  putBoardDirById = (
    { id }: { id: number } | PutBoardDirById_,
    boardDirDTO: defs.BoardDirDTO,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityString>({
      url: `/board-dir/${id}`,
      method: "PUT",
      data: boardDirDTO,
      ...params,
    });

  /**
   * 删除看板目录
   *
   * @tags 公共看板目录模块
   * @request DELETE: /board-dir/{id}
   * @secure
   */
  deleteBoardDirById = ({ id }: { id: number } | DeleteBoardDirById_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityString>({
      url: `/board-dir/${id}`,
      method: "DELETE",
      ...params,
    });
}

export default new PublicBoardDir();
